<template>
  <div class="divBox">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <div class="header-box">
          <div class="header">
            <div class="dot"></div>
            基本信息
          </div>
          <div class="company-box">
            <div class="company-info">
              <div class="row">
                <div class="item">姓名：{{ userInfo.real_name }}</div>
                <div class="item">
                  性别：<span v-if="userInfo.sex == 1">男</span
                  ><span v-else-if="userInfo.sex == 2">女</span
                  ><span v-else>未知</span>
                </div>
              </div>
              <div class="row">
                <div class="item">身份证号：{{ userInfo.card_code }}</div>
                <div class="item">所属公司：{{ userInfo.company }}</div>
              </div>
              <div class="row">
                <div class="item">联系电话：{{ userInfo.phone }}</div>
                <div class="item">
                  状态：<span v-if="userInfo.status == 1">已注册</span
                  ><span v-else-if="userInfo.status == 0">未注册</span
                  ><span v-else-if="userInfo.status == 2">已删除</span>
                </div>
              </div>
            </div>
            <div class="statistics-box">
              <div class="item">
                <img
                  src="https://tv.ytuy.cn/uploads/def/20240318/e29c9218929e8240fd9e22d39e77e22c.png"
                  class="img"
                />
                <div>
                  <div class="title">首充数量</div>
                  <div class="num">{{ userInfo.sale_save_count }}</div>
                </div>
              </div>
              <div class="item">
                <img
                  src="https://tv.ytuy.cn/uploads/def/20240318/90eec6c606440f0a38a102af0d8edc74.png"
                  class="img"
                />
                <div>
                  <div class="title">开卡数量</div>
                  <div class="num">{{ userInfo.sale_count }}</div>
                </div>
              </div>
              <div class="item">
                <img
                  src="https://tv.ytuy.cn/uploads/def/20240318/3dcc65b724ea42d37e5f89b0fe4070d1.png"
                  class="img"
                />
                <div>
                  <div class="title">激活数量</div>
                  <div class="num">{{ userInfo.sale_open_count }}</div>
                </div>
              </div>
              <div class="item" />
            </div>
          </div>
        </div>
        <div class="header">
          <div class="dot"></div>
          开卡情况
        </div>
      </div>
      <el-table
        v-loading="listLoading"
        :data="tableData.data"
        style="width: 100%"
        size="mini"
        name="m1"
        :row-key="
          row => {
            return row.id;
          }
        "
      >
        <el-table-column prop="real_name" label="业务办理人" />
        <el-table-column prop="card_code" label="销售时间" />
        <el-table-column prop="real_name" label="业务类型" />
        <el-table-column prop="card_code" label="联系电话" />
        <el-table-column prop="real_name" label="业务金额" />
        <el-table-column prop="card_code" label="激活状态" />
        <el-table-column prop="phone" label="是否首充" />
        <el-table-column prop="company" label="业务卡类型" />
        <el-table-column prop="phone" label="办理数量" />
        <el-table-column prop="company" label="创建时间" />
      </el-table>

      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>
  </div>
</template>
<script>
import { staffDetail, staffSallList } from "@/api/staff.js";
export default {
  name: "",
  data() {
    return {
      tableFrom: {
        page: 1,
        limit: 20,
        user_id: ""
      },
      listLoading: false,
      tableData: {
        data: [],
        total: 0
      },
      id: "",
      userInfo: {}
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 列表
    async getList(num) {
      this.listLoading = true;
      this.tableFrom.page = num || this.tableFrom.page;
      this.tableData.data = [];

      let param = this.tableFrom;
      staffSallList(param)
        .then(res => {
          this.tableData.data = res.data.list;
          this.tableData.total = res.data.count;
          this.listLoading = false;
        })
        .catch(res => {
          this.listLoading = false;
          this.$message.error(res.message);
        });
    },
    async getStaffDetail() {
      staffDetail(this.id)
        .then(res => {
          this.$set(this, "userInfo", res.data);
          this.tableFrom.user_id = res.data.user_id;
        })
        .catch(e => {
          this.$message.error(e);
        });
    },
    pageChange(page) {
      this.tableFrom.page = page;
      this.getList("");
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val;
      this.getList("");
    }
  },
  created() {},
  async mounted() {
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
      await this.getStaffDetail();
      await this.getList(1);
    }
  }
};
</script>

<style lang="scss" scoped>
.header-box {
  margin-bottom: 16px;
}
.header {
  display: flex;
  width: 100%;
  height: 61px;
  align-items: center;
  line-height: 24px;
  padding-left: 27px;
  font-size: 18px;
  color: #333333;
  border-bottom: 1px solid #eeeeee;

  .dot {
    width: 10px;
    height: 10px;
    border-radius: 5px;
    margin-right: 4px;
    background: #385be1;
  }
}

.company-box {
  display: flex;
  width: 100%;
  height: 221px;
  .company-info {
    display: flex;
    flex: 1.2;
    flex-direction: column;
    justify-content: space-around;
    background: url("https://tv.ytuy.cn/uploads/def/20240318/f69d0320293ee4c344e236f58e55c44d.png");
    background-size: 100% 100%;
    width: 728px;
    height: 100%;
    border-radius: 16px;
    font-size: 16px;
    color: #ffffff;
    .row {
      display: flex;
      padding: 0 16px;
      .item {
        flex: 1;
      }
    }
  }
  .statistics-box {
    flex: 2;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 44px;
    .item {
      display: flex;
      width: 25%;
      box-sizing: border-box;
      .img {
        height: 44px;
        width: 44px;
        margin-right: 14px;
      }
      .title {
        font-size: 18px;
        color: #aeb6d6;
      }
      .num {
        font-size: 22px;
      }
    }
  }
}
</style>
